package cn.mystyle.controller.account;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.mystyle.common.bean.BaseController;
import cn.mystyle.controller.user.UserController;
import cn.mystyle.model.user.UserInfo;
import cn.mystyle.service.account.AccountService;
import cn.mystyle.util.UserUtil;

/**
 * @author clark
 * 
 * 记账控制器
 */
@RestController
@RequestMapping(value = "/account/stat")
public class AccountController extends BaseController
{
    /**
     * 日志记录
     */
    private Logger logger = LoggerFactory.getLogger(UserController.class);
    
    /**
     * 账务业务类
     */
    @Autowired
    private AccountService accountService;
    
    /**
     * 获取用户
     * @param request HTTP 请求体
     * @param response HTTP 响应体
     * @param paramData 请求参数
     * @return String  
     */
    @RequestMapping(value = "/default", method = RequestMethod.POST)
    public String statDefault(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData)
    {
        logger.info("start stat default, param:{}", jsonData);
        
        // 获取当前登录用户
        UserInfo sessionUser = UserUtil.seesionUser(request);
        
        return accountService.statDefault(jsonData, sessionUser).toString();
    }
}
